package com.dxx.cloud.admin.controller.toc;

import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
import com.dxx.cloud.admin.constant.enums.ControllerRouter;
import io.swagger.v3.oas.annotations.Operation;
import jakarta.annotation.Resource;
import me.chanjar.weixin.common.error.WxErrorException;
import org.dromara.common.core.domain.R;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(ControllerRouter.TOC +"/customer")
public class WxMpController {

    @Resource
    private WxMaService wxMaService;

    @Operation(summary = "获得openid")
    @GetMapping("/getOpenid")
    public R<WxMaJscode2SessionResult> getOpenId(String code) throws WxErrorException {
        return R.ok(wxMaService.jsCode2SessionInfo( code));
    }

}
